<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Linkslists;
use App\Services\HtmlossService;
use App\Services\OutputService;
use Log,Exception;

class HtmlossController extends Controller
{
    public function emptyOssGenerate(Request $request)
    {
        // 当OSS内容为空时,生成OSS中的文件
        if (empty($request->links_id) || empty($request->sign)) return OutputService::error("链接不存在!");
        if (md5("oss".$request->links_id."generate") != $request->sign) return OutputService::error("链接不存在!");
        $links_id = $request->links_id;
        $links = Linkslists::getLinks($links_id);
        if (empty($links)) return OutputService::error("链接不存在!");
        HtmlossService::uploadHtml($links_id,$links->created_at);
        $day = date("Ymd",strtotime($links->created_at));
        return OutputService::success("SUCCESS!",["day"=>$day]);
    }
}
